package createpattern.prototype.deepcopy.trueexample2;

public class Student implements Cloneable{
    private String name;
    private String address;

    public Student(String name, String address) {
        this.name = name;
        this.address = address;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    // super.clone() 返回一个当前对象的浅拷贝，生成一个新对象。
    // 新对象的引用地址和原始对象不同，因此是一个新的 Student 对象。
    @Override
    protected Student clone() throws CloneNotSupportedException {
        return (Student) super.clone();
    }
}
